//
//  UIImage+Category.m
//  LCCommonTools
//
//  Created by Chance on 2023/8/24.
//

#import "UIImage+Category.h"

@implementation UIImage (Category)

+ (UIImage *)loadBundleName:(NSString *)bundleName ImageNamed:(NSString *)name type:(NSString *)type {
    NSString *mainBundlePath = [NSBundle mainBundle].bundlePath;
    NSString *bundlePath = [NSString stringWithFormat:@"%@/%@.bundle",mainBundlePath,bundleName];
    NSBundle *bundle = [NSBundle bundleWithPath:bundlePath];
    if (bundle == nil) {
//        bundlePath = [NSString stringWithFormat:@"%@/%@",mainBundlePath,@"Frameworks/LCPhotoSelector.framework/LCPhotoSelector.bundle"];
        bundlePath = [NSString stringWithFormat:@"%@/Frameworks/%@.framework/%@.bundle",mainBundlePath,bundleName,bundleName];
        bundle = [NSBundle bundleWithPath:bundlePath];
    }
    if ([UIImage respondsToSelector:@selector(imageNamed:inBundle:compatibleWithTraitCollection:)]) {
        return [UIImage imageNamed:name inBundle:bundle compatibleWithTraitCollection:nil];
    } else {
        return [UIImage imageWithContentsOfFile:[bundle pathForResource:name ofType:type]];
    }
}

@end
